
{% extends 'base_main.html' %}

{% block meta %}
  {{ block.super }}
{% endblock %}

{% block title %}
  <title>文章 - DDF博客管理系统</title>
{% endblock %}

{% block css %}
  {{ block.super }}
{% endblock %}

{% block js %}
    <script src="/static/js/jquery-2.1.4.min.js"></script>
    <script src="/static/js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/static/js/html5shiv.min.js" type="text/javascript"></script>
    <script src="/static/js/respond.min.js" type="text/javascript"></script>
    <script src="/static/js/selectivizr-min.js" type="text/javascript"></script>
{% endblock %}

{% block content%}
<section class="container-fluid">
    <header>
        <nav class="navbar navbar-default navbar-fixed-top">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">切换导航</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
                    <a class="navbar-brand" href="{% url 'user:index' %}">SAMSARA</a> </div>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="">消息 <span class="badge">1</span></a></li>
                        <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ user.username }}<span class="caret"></span></a>
                            <ul class="dropdown-menu dropdown-menu-left">
                                <li><a title="查看或修改个人信息" data-toggle="modal" data-target="#seeUserInfo">个人信息</a></li>
                                <li><a title="查看您的登录记录" data-toggle="modal" data-target="#seeUserLoginlog">登录记录</a></li>
                            </ul>
                        </li>
                        <li><a href="{% url 'user:logout' %}" onClick="if(!confirm('是否确认退出？'))return false;">退出登录</a></li>
                        <li><a data-toggle="modal" data-target="#WeChat">帮助</a></li>
                    </ul>
                    <form action="" method="post" class="navbar-form navbar-right" role="search">
                        <div class="input-group">
                            <input type="text" class="form-control" autocomplete="off" placeholder="键入关键字搜索" maxlength="15">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="submit">搜索</button>
                            </span> </div>
                    </form>
                </div>
            </div>
        </nav>
    </header>
    <div class="row">
        <aside class="col-sm-3 col-md-2 col-lg-2 sidebar">
            <ul class="nav nav-sidebar">
                <li><a href="{% url 'user:index' %}">报告</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li class="active"><a href="{% url 'article:article' %}">文章</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a href="{% url 'category:category' %}">栏目</a></li>
            </ul>
        </aside>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
            <form action="" method="post" >
                <h1 class="page-header">操作</h1>
                <ol class="breadcrumb">
                    <li><a href="{% url 'article:add_article' %}">增加文章</a></li>
                </ol>
                <h1 class="page-header">管理 <span class="badge">{{ articles.count }}</span></h1>
                <div class="table-responsive">
                    <table class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th><span class="glyphicon glyphicon-th-large"></span> <span class="visible-lg">选择</span></th>
                            <th><span class="glyphicon glyphicon-file"></span> <span class="visible-lg">标题</span></th>
                            <th><span class="glyphicon glyphicon-list"></span> <span class="visible-lg">栏目</span></th>
                            <th class="hidden-sm"><span class="glyphicon glyphicon-tag"></span> <span class="visible-lg">标签</span></th>
                            <th class="hidden-sm"><span class="glyphicon glyphicon-comment"></span> <span class="visible-lg">关键字</span></th>
                            <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">日期</span></th>
                            <th><span class="glyphicon glyphicon-pencil"></span> <span class="visible-lg">操作</span></th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for i in ddf %}
                        <tr>
                            <td><input type="checkbox" class="input-control" name="checkbox[]" value="" /></td>
                            <td class="article-title">{{ i.title }}</td>
                            <td>{{ i.category.name }}</td>
                            <td class="hidden-sm">{{ i.tags }}</td>
                            <td class="hidden-sm">{{ i.keywords }}</td>
                            <td>{{ i.create_time }}</td>
                            <td><a href="{% url 'article:edit_article' i.id %}">修改</a> <a href="{% url 'article:del_article' i.id %}">删除</a></td>
                        </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>
                <footer class="message_footer">
                    <nav>
                        <div class="btn-toolbar operation" role="toolbar">
                            <div class="btn-group" role="group"> <a class="btn btn-default" onClick="select()">全选</a> <a class="btn btn-default" onClick="reverse()">反选</a> <a class="btn btn-default" onClick="noselect()">不选</a> </div>
                            <div class="btn-group" role="group">
                                <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="删除全部选中" name="checkbox_delete">删除</button>
                            </div>
                        </div>

                        <ul class="pagination pagenav">
                            {% if ddf.has_previous %}
                            <li><a href="{% url 'article:article' %}?page={{ ddf.previous_page_number }}" aria-label=""> <span aria-hidden="true">&laquo;</span> </a> </li>
                            {% endif %}
                            {% for i in ddf.paginator.page_range %}
                            <li><a href="{% url 'article:article' %}?page={{ i }}">{{ i }}</a></li>
                            {% endfor %}
                            {% if ddf.has_next %}
                            <li><a href="{% url 'article:article' %}?page={{ ddf.next_page_number }}" aria-label=""> <span aria-hidden="true">&raquo;</span> </a> </li>
                            {% endif %}
                        </ul>

                    </nav>
                </footer>

            </form>
        </div>
    </div>
</section>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/admin-scripts.js"></script>
<script>
//是否确认删除
$(function(){
	$("#main table tbody tr td a").click(function(){
		var name = $(this);
		var id = name.attr("rel"); //对应id
		if (event.srcElement.outerText == "删除")
		{
			if(window.confirm("此操作不可逆，是否确认？"))
			{
				$.ajax({
					type: "POST",
					url: "/Article/delete",
					data: "id=" + id,
					cache: false, //不缓存此页面
					success: function (data) {
						window.location.reload();
					}
				});
			};
		};
	});
});
</script>
{% endblock %}
